package com.kaifamiao.month05.day09;

import javax.swing.plaf.basic.BasicListUI;
import java.util.concurrent.BlockingQueue;

public class Eat extends Thread{

    private BlockingQueue<String> bq;
    public Eat(String name, BlockingQueue<String> bq) {
        super(name);
        this.bq = bq;
    }

    @Override
    public void run() {
        while (true) {
            try {
                sleep(1000);
                bq.take();
                System.out.println(getName() + "吃了一个包子");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
